﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Prefs {

	public static int CurrentLevel
    {
        get { return PlayerPrefs.GetInt("current_level", 1); }
        set { PlayerPrefs.SetInt("current_level", value); }
    }

    public static int CurrentScore
    {
        get { return PlayerPrefs.GetInt("current_score"); }
        set { PlayerPrefs.SetInt("current_score", value); }
    }

    public static string SavedData
    {
        get { return PlayerPrefs.GetString("saved_data", null); }
        set { PlayerPrefs.SetString("saved_data", value); }
    }

    public static bool IsSoundEnabled
    {
        get { return PlayerPrefs.GetInt("is_sound_enabled", 1) == 1; }
        set { PlayerPrefs.SetInt("is_sound_enabled", value ? 1 : 0); }
    }

    public static bool IsVibrateEnabled
    {
        get { return PlayerPrefs.GetInt("is_vibrate_enabled", 1) == 1; }
        set { PlayerPrefs.SetInt("is_vibrate_enabled", value ? 1 : 0); }
    }

    public static int CurrentSliceItem
    {
        get { return PlayerPrefs.GetInt("current_slice_item"); }
        set { PlayerPrefs.SetInt("current_slice_item", value); }
    }

    public static bool IsSliceUnlocked(int index)
    {
        return PlayerPrefs.GetInt("is_slice_unlocked_" + index) == 1;
    }

    public static void SetSliceUnlocked(int index, bool value)
    {
        PlayerPrefs.SetInt("is_slice_unlocked_" + index, value ? 1 : 0);
    }

    public static int NumAdRemainder(int index)
    {
        return PlayerPrefs.GetInt("num_ad_remainder_" + index, GameConfig.instance.unlockSliceNumWatchAd);
    }

    public static void SetNumAdRemainder(int index, int value)
    {
        PlayerPrefs.SetInt("num_ad_remainder_" + index, value);
    }
}
